package com.biyao.controller.base;

import java.util.Arrays;
import java.util.Map;


import com.baomidou.mybatisplus.plugins.Page;
import com.biyao.schedulingcommon.response.BaseMsg;
import com.biyao.schedulingcommon.response.SuccessMsg;
import com.biyao.schedulingentity.base.TBearingEntity;
import com.biyao.schedulingentity.base.TBearingEntityCopy;
import com.biyao.service.model.base.imp.TBearingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



/**
 * 
 *
 * @author code generator
 * @date 2020-04-26 17:59:59
 */
@Api(tags = {"轴承"})
@RestController
@RequestMapping("api/v1/tbearing")
public class TBearingController {

    @Autowired
    private TBearingService tBearingService;

    /**
    * 待完善
    * @param pageNum 待完善
    * @param pageSize 待完善
    * @return  待完善
    */
    /**
    *
    * @ApiOperation(value = "列表")
    * @GetMapping
    */
    @ApiOperation(value = "列表")
    @GetMapping
    public BaseMsg list(@RequestParam(defaultValue = "1") Integer pageNum,
                        @RequestParam(defaultValue = "10") Integer pageSize
    ) {
        Page page = tBearingService.list(pageNum, pageSize);

        return new SuccessMsg(page);
    }


    /**
    * 待完善
    * @return 待完善
    */

     @ApiOperation(value = "详情")
     @GetMapping("/info/{id}")
    public BaseMsg info(@PathVariable("id") Integer id) {
         TBearingEntityCopy tBearing = tBearingService.selectNowState(id);
         return new SuccessMsg(tBearing);
    }

    /**
    * 待完善
    * @return 待完善
    */

    @ApiOperation(value = "保存")
    @PostMapping

    public BaseMsg save(@RequestBody TBearingEntity tBearing) {
            tBearingService.insert(tBearing);
        return new SuccessMsg();
    }

    /**
    * 待完善
    * @return 待完善
    */

    @ApiOperation(value = "更新")
    @PutMapping
    public BaseMsg update(@RequestBody TBearingEntityCopy tBearing) {

            tBearingService.updateTBearingCopy(tBearing);

        return new SuccessMsg();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("delete/{id}")
    public BaseMsg delete(@PathVariable("id") Integer id) {
        tBearingService.deleteById(id);
        return new SuccessMsg();
    }



}
